#ifndef __EMB_TOPIC_H
#define __EMB_TOPIC_H

#include "emb.h"



#define EMB_EVENT_TOPIC_MSG (1<<0)


typedef struct{
    emb_fifo_ctrl_t Fifo;
    const char      *TopicName;
    emb_topic_ctrl_t *Next;
    void *SubscriberList;
} emb_topic_ctrl_t;

int emb_topic_init(emb_topic_ctrl_t* Topic,const char* TopicName,uint8_t* Buf,size_t BufSize);

int emb_topic_subscribe(emb_task_id_t Id,emb_topic_ctrl_t *Topic);

int emb_topic_subscribe2(emb_task_id_t Id,const char* TopicName);

int emb_topic_unsubscribe(emb_task_id_t Id,emb_topic_ctrl_t *Topic);

int emb_topic_unsubscribe2(emb_task_id_t Id,const char* TopicName);

int emb_topic_msg_send(emb_topic_ctrl_t *Topic,const uint8_t* Buf,uint16_t Size);

int emb_topic_msg_send2(const char* TopicName,const uint8_t* Buf,uint16_t Size);

void emb_topic_handler();

#endif
